package it.infodea.tapestrydea.pages;

import it.infodea.tapestrydea.RepositoryUploadedFileBean;
import it.infodea.tapestrydea.services.jcr.nodes.wrappers.JcrFileNode;

import javax.jcr.PathNotFoundException;
import javax.jcr.RepositoryException;
import javax.jcr.ValueFormatException;

import org.apache.tapestry5.annotations.Environmental;
import org.apache.tapestry5.services.PropertyOutputContext;

public class FilePropertyDisplayBlocks {

	@Environmental
	private PropertyOutputContext context;

	private JcrFileNode node = null;

	public JcrFileNode getFile() throws ValueFormatException, PathNotFoundException, RepositoryException {
		return node;
	}

	public boolean isNotNull() {
		RepositoryUploadedFileBean p = (RepositoryUploadedFileBean) context.getPropertyValue();
		if (p != null) {
			node = p.getJcrFile();
		} else {
			node = null;
		}
		return node != null;
	}
}
